<template>
  <div>
    <search></search>
    <banner></banner>

    <div class="nav-top" @touchstart="brand">品牌制造商直供</div>

    <ul class="nav-content">
      <li v-for="item in bannerArr" :key="item.id">
        <span
          :style="{
            'background-image': 'url(' + item.new_pic_url + ')',
            'background-repeat': 'no-repeat',
            'background-size': 'cover',
          }"
        >
          <p>{{ item.name }}</p>
          <p>{{ item.floor_price }}元起</p>
        </span>
      </li>
    </ul>

    <div class="nav-bottom">
      <p>新品首发</p>
      <p>查看全部</p>
    </div>

    <ul class="goodsNew">
      <router-link :to="`/home/${item.id}`" tag="li" v-for="item in newGoods" :key="item.id">
        <img :src="item.list_pic_url" alt="" />
        <p class="goodsNew-p1">{{ item.name }}</p>
        <p class="goodsNew-p2">{{ item.goods_brief }}</p>
        <p class="goodsNew-p3">￥{{ item.retail_price }}</p>
      </router-link>
    </ul>

    <div class="nav-bottom nav-bottom2">
      <p>人气推荐·好物精选</p>
      <p>查看全部</p>
    </div>

    <ul class="goodsNew">
      <router-link :to="`/home/${item.id}`" tag="li" v-for="item in hotGoods" :key="item.id">
        <img :src="item.list_pic_url" alt="" />
        <p class="goodsNew-p1">{{ item.name }}</p>
        <p class="goodsNew-p2">{{ item.goods_brief }}</p>
        <p class="goodsNew-p3">￥{{ item.retail_price }}</p>
      </router-link>
    </ul>

    <div class="selected-top">专题精选<span></span></div>

    <ul class="selected-top-goods">
      <li v-for="item in topicList" :key="item.id">
        <img :src="item.item_pic_url" alt="" />
        <div class="selected-top-a">
          <p>{{ item.title }}</p>
          <p>{{ item.price_info }}元起</p>
        </div>
        <p class="selected-top-a-p">{{ item.subtitle }}</p>
      </li>
    </ul>

    <ul class="selected-goodslist">
      <li v-for="item in newCategoryList" :key="item.id">
        <p class="selected-goodslist-p1">{{ item.name }}好物</p>
        <ul class="selected-goodslist2">
          <router-link :to="`/home/${list.id}`" tag="li" v-for="list in item.goodsList" :key="list.id">
            <img :src="list.list_pic_url" alt="" />
            <p class="selected-goodslist2-p1">{{ list.name }}</p>
            <p class="selected-goodslist2-p2">￥{{ list.retail_price }}</p>
          </router-link>
          <div>
            <p>{{ item.name }}好物</p>
            <span></span>
          </div>
        </ul>
      </li>
    </ul>
  </div>
</template>

<script>
//引入组件
import search from "../../components/homecomp/search";
import banner from "../../components/homecomp/banner";

import { home } from "@/api/home/index";
export default {
  data() {
    return {
      bannerArr: [],
      newGoods: [],
      hotGoods: [],
      topicList: [],
      newCategoryList: [],
      goodsList:[],
    };
  },
  methods:{
    brand(){
      this.$router.push({path: '/home/brand'});
    }
  },
  //挂载组件名
  components: {
    search,
    banner,
  },
  computed: {},
  created() {
    home().then((res) => {
      console.log(res);
      this.bannerArr = res.brandList;
      this.newGoods = res.newGoods;
      this.hotGoods = res.hotGoods;
      this.topicList = res.topicList;
      this.newCategoryList = res.newCategoryList;
      console.log(this.newCategoryList);
    });
  },
  mounted() {
    
  },
};
</script>


<style scoped lang="scss">
* {
  margin: 0;
  padding: 0;
}

@mixin fle {
  display: flex;
  justify-content: center;
  align-items: center;
}

@mixin over-hidd {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-top {
  width: 100%;
  height: 56px;
  line-height: 56px;
}

.nav-content {
  @include fle;

  flex-wrap: wrap;
  justify-content: space-around;
  span {
    display: inline-block;
    width: 182px;
    height: 120px;
    margin-bottom: 5px;
  }
  p {
    text-align: left;
    margin: 12px 0 12px 12px;
  }
}

.nav-bottom {
  width: 100%;
  height: 130px;
  background: url(../../assets/img/images/bgnew.png) no-repeat;
  background-size: cover;
  border: 10px solid #f4f4f4;
  border-left: none;
  border-right: none;
  display: flex;
  flex-direction: column;
  justify-content: center;

  & p:nth-child(1) {
    color: #8c9bae;
    font-size: 16px;
    margin: 10px 0 15px 0;
  }
  & p:nth-child(2) {
    width: 90px;
    height: 25px;
    line-height: 25px;
    background: #d8e4f0;
    font-size: 10px;
    color: #8c9bae;
    margin: 0 auto;
  }
}

.goodsNew {
  width: 100%;
  height: 250px;
  // 超出显示滚动条
  overflow: scroll;
  display: flex;
  flex-wrap: nowrap;
  li {
    width: 150px;
    height: 205px;
    margin-left: 10px;
    border-right: 1px solid #d8e4f0;
    text-align: left;
    img {
      width: 140px;
      height: 140px;
    }
    .goodsNew-p1 {
      font-size: 15px;
      font-weight: bolder;
      width: 125px;
      height: 20px;
      @include over-hidd;
      margin: 4px 0 15px 5px;
    }
    .goodsNew-p2 {
      width: 125px;
      height: 16px;
      color: #8a8a8a;
      @include over-hidd;
      margin: 4px 0 12px 5px;
    }
    .goodsNew-p3 {
      color: #9c3232;
      margin: 4px 0 12px 5px;
    }
  }
}
.nav-bottom2 {
  background: url(../../assets/img/images/bgtopic.png) no-repeat;
  & p:nth-child(1) {
    color: #b1a279;
  }
  & p:nth-child(2) {
    color: #b1a279;
    background-color: #f4e9cb;
  }
}

.selected-top {
  border-top: 10px solid #f4f4f4;
  height: 50px;
  line-height: 50px;
  span {
    display: inline-block;
    background: url(../../assets/img/images/right.png) no-repeat;
    background-size: cover;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    margin-left: 8px;
  }
}

.selected-top-goods {
  width: 100%;
  height: 250px;
  overflow: scroll;
  display: flex;
  flex-wrap: nowrap;
  li {
    width: 300px;
    height: 250px;
    img {
      width: 288px;
      height: 163px;
      border-radius: 5px;
      margin-right: 10px;
    }
    & img:first-child {
      margin-left: 10px;
    }
    .selected-top-a {
      display: flex;
      justify-content: space-between;
      margin-left: 10px;
      & p:first-child {
        font-size: 14px;
        font-weight: bolder;
        margin: 4px 0 15px 0;
      }
      & p:last-child {
        color: #9c3232;
        margin-top: 5px;
      }
    }
    .selected-top-a-p {
      text-align: left;
      width: 216px;
      margin-left: 10px;
      color: #8a8a8a;
      @include over-hidd;
    }
  }
}

.selected-goodslist {
  width: 100%;
  background-color: #f4f4f4;
  padding-bottom: 40px;
  .selected-goodslist-p1 {
    height: 50px;
    line-height: 50px;
  }
}

.selected-goodslist2 {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-around;
  li {
    width: 180px;
    height: 215px;
    background-color: #fff;
    margin-bottom: 5px;
    img {
      width: 151px;
      height: 151px;
    }
    .selected-goodslist2-p1 {
      @include over-hidd;
      width: 165px;
      text-align: left;
      margin: 12px 0 2.5px 10px;
    }
    .selected-goodslist2-p2 {
      text-align: left;
      color: #9c3232;
      margin: 12px 0 2.5px 10px;
    }
  }
  div {
    width: 180px;
    height: 215px;
    background-color: #fff;
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    p {
      font-size: 17px;
      margin-bottom: 30px;
    }
    span {
      display: inline-block;
      width: 35px;
      height: 35px;
      background: url(../../assets/img/images/rightbig.png) no-repeat;
      background-size: cover;
      margin: 0 auto;
    }
  }
}
</style>